package com.pengtu.gsj.service.impl.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.system.CodeDao;
import com.pengtu.gsj.entity.app.Code;
import com.pengtu.gsj.service.system.CodeService;

@Transactional
@Service
public class CodeServiceImpl implements CodeService {
	
	@Autowired
	private CodeDao codeDao;

	@Override
	public List<Code> getCodes(QueryFilter queryFilter) {
		return codeDao.find(queryFilter);
	}

	@Override
	public Page<Code> findCodes(Page<Code> page, QueryFilter queryFilter) {
		return codeDao.findPage(page, queryFilter);
	}

	@Override
	public Code getCode(String id) {
		return codeDao.get(id);
	}

	@Override
	public void saveCode(Code code) {
		codeDao.save(code);
	}
	
	@Override
	public void deleteCode(String id) {
			codeDao.delete(id);
			
	}

	@Override
	public boolean checkId(Integer category, String codeId) {
		if((codeDao.getCodeByCategory(category, codeId))!=null){;
			return false;
		}else {
			return true;
		}
		
	}
}
